#include "EventMgr.h"

CEventMgr::CEventMgr( void )
{
	m_akEvents.clear();
}

CEventMgr::~CEventMgr( void )
{

}

void CEventMgr::AddEvent( EventType eType,EventFun pFunc,const CParamMap& rkMap /*= ""*/ )
{
	EventInfo kInfo;
	kInfo.pFun = pFunc;
	kInfo.kMap = rkMap;

	m_akEvents[eType].push_back(kInfo);
}

void CEventMgr::Fire( EventType eType )
{
	vector<EventInfo>& rakEventInfo = m_akEvents[eType];
	for (int i = 0;i < (int)rakEventInfo.size();i++)
	{
		EventInfo& rkInfo = rakEventInfo[i];
		if (rkInfo.pFun == NULL)
		{
			continue;
		}

		rkInfo.pFun(rkInfo.kMap);
	}

	rakEventInfo.clear();
	return;
}

void CEventMgr::Clear()
{
	m_akEvents.clear();
}

